#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include "unitTest3.h"


int unitTest3() {
    
    int seed = 1000;
    int numPlayer = 2;
    
	struct gameState G;
	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, 
		   sea_hag, tribute, smithy};
	
	
	printf("=========================\n TESTING GAINCARD() FUNCTION \n=========================\n");
	
	initializeGame(numPlayer, k, seed, &G);
	
	G.supplyCount[1] = 0;
	if(gainCard(1, &G, 0, 0)==-1){
		printf("TEST PASSED: There is no supply\n");
	} else {
		printf("TEST FAILED: Should fail when there is no supply\n");
	}
		
	//Test with 0 flag- should go in discard
	G.supplyCount[1] = 1;
	gainCard(1, &G, 0, 0);
	
	if(G.discardCount[0] == 1){
		printf("TEST PASSED: card added to discard pile\n");
	} else {
		printf("TEST FAILED: card added to discard pile\n");
	}
		
	if(G.discard[0][G.discardCount[0]-1] == 1){
		printf("TEST PASSED: new card in discard is correct\n");
	} else {
		printf("TEST FAILED: new card in discard is incorrect\n");
	}
	
	//Test with flag of 1
	G.supplyCount[1] = 1;
	int prevDeck = G.deckCount[0];
	
	gainCard(1, &G, 1, 0);
	
	if(G.deckCount[0] == prevDeck+1){
		printf("TEST PASSED: card added to deck pile\n");
	} else {
		printf("TEST FAILED: card added to deck pile\n");
	}
		
	if(G.deck[0][G.deckCount[0]-1] == 1){
		printf("TEST PASSED: new card in deck is correct\n");
	} else {
		printf("TEST FAILED: new card in deck is incorrect\n");
	}
	
	//Test with flag of 2
	G.supplyCount[1] = 1;
	gainCard(1, &G, 2, 0);
	
	if(G.handCount[0] == 6){
		printf("TEST PASSED: card added to hand pile\n");
	} else {
		printf("TEST FAILED: card added to hand pile\n");
	}
		
	if(G.hand[0][G.handCount[0]-1] == 1){
		printf("TEST PASSED: new card in hand is correct\n");
	} else {
		printf("TEST FAILED: new card in hand is incorrect\n");
	}
	



    return 0;
}


